﻿using DAL;
using models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
   public class ProductTypeMarager
    {
        ProductTypeService service = new ProductTypeService();
        // 商品类型
        //新增商品类型
        public bool AddProductType(ProductType productType ) 
        {
            return service.AddProductType(productType);
        }
        //查询所有商品类型
        public List<ProductType> SumProductCount()
        {
           
            List<ProductType> counts = new List<ProductType>();
            SqlDataReader reader = service.SumProductType();
            while (reader.Read())
            {
                counts.Add(new ProductType(
                    reader.GetInt32(0),
                    reader.GetString(1),
                    reader.GetInt32(2)
                    )
                    );
            }
            DBhelper.Close();
            return counts;

        }
        // 商品类型
        public List<ProductType> GetProductCount(int id)
        {
            List<ProductType> Cailist = new List<ProductType>();
            ProductType product = null;
            SqlDataReader reader = service.GetProductType(id);
            while (reader.Read())
            {
                product = new ProductType(
                    reader.GetInt32(0),
                    reader.GetString(1),
                     reader.GetInt32(2)
                   );
                Cailist.Add(product);
            }
            reader.Close();
            return Cailist;
        }
        public List<ProductType> GetProductCount2()
        {
            List<ProductType> Cailist = new List<ProductType>();
            ProductType product = null;
            SqlDataReader reader = service.GetProductType2();
            while (reader.Read())
            {
                product = new ProductType(
                    reader.GetInt32(0),
                    reader.GetString(1),
                     reader.GetInt32(2)
                   );
                Cailist.Add(product);
            }
            reader.Close();
            return Cailist;
        }
    }
}
